package com.leyu.mall.site.home.controller;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import com.leyu.mall.admin.cms.service.ICmsChannelService;
import com.leyu.mall.admin.goods.domain.GoodsBase;
import com.leyu.mall.admin.goods.service.IGoodsBaseService;

/**
 * 〈一句话功能简述〉 〈功能详细描述〉
 * 
 * @author OOKK
 * @see [相关类/方法]（可选）
 * @since [产品/模块版本] （可选）
 */
@Controller
@Scope(value = "prototype")
@RequestMapping("")
public class SiteGoodsController {

	@Resource(name = "goodsBaseServiceImpl")
	private IGoodsBaseService goodsBaseServiceImpl;

	@ExceptionHandler(Exception.class)
	public String exception(Exception e, HttpServletRequest request) {
		request.setAttribute("exception", e);
		return "/error.html";
	}
	
	@RequestMapping(value = "item/{itemIDS}", method = RequestMethod.GET)
	public String delete(Model model, @PathVariable String itemIDS) {
		try {
			System.out.println("-------111111-goodsID-----------------------"+itemIDS); 
			Long goodsID =Long.parseLong(itemIDS.split("_")[2]);
			model.addAttribute("itemdetail",goodsBaseServiceImpl.getGoodsBaseById(goodsID));
			
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return "goods/item.html";
	}

}
